import axios from 'axios'
import nprogress from 'nprogress'
import 'nprogress/nprogress.css'
const mockserver = axios.create({
  baseURL: '/mock',
  // 请求超时时间
  timeout: 5000
})
// console.log(nprogress)
// start开始
// 拦截器
mockserver.interceptors.request.use((config) => {
  // config里面的属性有一个是请求头,headers
  nprogress.start()
  return config
})

// 拦截器
mockserver.interceptors.response.use(
  (res) => {
    setTimeout(() => nprogress.done(), 1000)
    return res.data
  },
  () => {}
)

export default mockserver
